﻿Public Class Type
    Public l As New Label
    Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
        If txttype.Text.Trim = "" Then
            MessageBox.Show("Please Input Type")
            txttype.Focus()
            Exit Sub
        End If
        cmd.Parameters("@name") = txttype.Text
        Me.DialogResult = Windows.Forms.DialogResult.OK
        If Me.l.Text = "" Then
            cmd.ExecuteNonQuery("INSERT INTO [Type] values(@name,1)")
        Else
            cmd.Parameters("@Id") = l.Text
            cmd.ExecuteNonQuery("UPDATE [Type] SET TypeName=@name WHERE TypeId=@Id")
        End If
        Me.DialogResult = Windows.Forms.DialogResult.OK
    End Sub

    Private Sub Type_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class